package com.basic.java.threads.proxy;

/**
 * 代理类
 * 创建时间：2022/4/18 20:50
 *
 * @author gejin
 */
public class StaticProxy {
    public static void main(String[] args) {
        new Thread(() -> System.out.println("we are wedding！")).start();

        new WeddingCompany(new You("吴亦凡")).happyMarry();
    }
}

/**
 * 结婚的接口
 */
interface Marry {
    public void happyMarry();
}

/**
 * 实现结婚这个接口
 */
class You implements Marry {
    String userName;

    public You(String userName) {
        this.userName = userName;
    }

    @Override
    public void happyMarry() {
        System.out.println(String.format("%s要结婚了， 超高兴的哦！", this.userName));
    }
}

/**
 * 实现结婚这个接口
 */
class WeddingCompany implements Marry {
    private Marry target;

    public WeddingCompany(Marry target) {
        this.target = target;
    }

    @Override
    public void happyMarry() {
        // 结婚之前
        befor();
        // 结婚这个接口调用方法
        this.target.happyMarry();
        // 结婚之后
        after();
    }

    private void befor() {
        System.out.println("结婚之前， 布置婚礼现场！");
    }

    private void after() {
        System.out.println("结婚之后， 收尾款！");
    }
}
